package etc.com.market;

import java.util.ArrayList;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import etc.com.market.CustomViewGroup;

public class ListWorkAdapter extends ArrayAdapter<Work> {
	ArrayList<Work> array;
	int resource;
	Context context;

	public ListWorkAdapter(Context context, int textViewResourceId,
			ArrayList<Work> objects) {
		super(context, textViewResourceId, objects);
		this.context = context;
		resource = textViewResourceId;
		array = objects;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View workView = convertView;

		if (workView == null) {
			workView = new CustomViewGroup(getContext());
		}

		final Work work = array.get(position);

		if (work != null) {
			TextView workContent = ((CustomViewGroup) workView).workContent;

			TextView title = ((CustomViewGroup) workView).title;
			TextView content = ((CustomViewGroup) workView).content;

			title.setText(work.getTitle());
			content.setText(work.getontent());
			workContent.setText(work.getContent());

		}
		return workView;
	}
}
